home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13848 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: hubcap.clemson.edu!hubcap!mjs
  2. From: mjs@hubcap.clemson.edu (M. J. Saltzman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help:what is wrong this code?
  5. Date: 10 Apr 96 14:37:10 GMT
  6. Organization: Clemson University
  7. Message-ID: <mjs.829147030@hubcap>
  8. References: <4k3p3q$n76@brahms.udel.edu> <4k4hi3$5hm@sparcserver.lrz-muenchen.de> <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
  9. NNTP-Posting-Host: hubcap.clemson.edu
  10. X-Newsreader: NN version 6.5.0 #1
  11.  
  12. Norma Mathews <n9341884@henson.cc.wwu.edu> writes:
  13.  
  14. >On 6 Apr 1996, Kurt Watzka wrote:
  15.  
  16. >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
  17. >>
  18. >> >Why it give me 0.0000?
  19. >>
  20. >> >#include <stdio.h>
  21. >> >main () {
  22. >> >double a=9.008;
  23. >> >printf("%f\n",sqrt(a));
  24. >> >return 0;
  25. >> >}
  26.  
  27. >your printf specifer needs to be "%lf", not "%f", since a is a double
  28.  
  29. If you RTFM, you will find that "%f" *is* the printf() format
  30. specifier for a double.  The *scanf()* format specifer for a double is
  31. "%lf".  There is *no* "%lf" specifier for printf() in ANSI C.
  32.  
  33. I bet his problem is failure to #include <math.h>.
  34.  
  35.  
  36. -- 
  37.         Matthew Saltzman
  38.         Clemson University Math Sciences
  39.         mjs@clemson.edu
  40. -- 
  41.         Matthew Saltzman
  42.         Clemson University Math Sciences
  43.         mjs@clemson.edu
  44.